import { done } from 'nprogress'
import { get, post, setToken } from '../util/request'

export default {
    install: function (Vue) {
        Vue.mixin({
            methods: {
                $get(url, params) {
                    return get(url, params)
                },
                $post(url, params) {
                    return post(url, params)
                },
                $setToken() {
                    setToken()
                },
                //警告提示框
                $msg_w(message, duration = 3000) {
                    this.$message({
                        showClose: true,
                        message,
                        type: 'warning',
                        duration
                    })
                },

                //成功提示框
                $msg_s(message, duration = 3000) {
                    this.$message({
                        showClose: true,
                        message,
                        type: 'success',
                        duration
                    })
                },

                //错误消息提示框
                $msg_e(message, duration = 3000) {
                    this.$message({
                        showClose: true,
                        message,
                        type: 'error',
                        duration
                    })
                },
                
                $con_f(message) {
                    return new Promise((resolve, reject) => {
                        this.$confirm(message)
                            .then(res => {
                                resolve()
                            })
                            .catch(_ => { });
                    })

                }
            },
        })
    }
}